package com.limao.CacheManager;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.AsyncContext;
import javax.servlet.http.HttpServletResponse;

import com.limao.DBDataClass.CrowdSysParamDataClass;
import com.limao.DBDataClass.SysProjectCateDataClass;
import com.limao.DBDataClass.SysRmbSelectdataClass;
import com.limao.DBDataClass.SysVersionDataClass;
import com.limao.Model.LzPluginException;
import com.limao.Model.PublicData;
import com.limao.Model.RecvData;
import com.limao.Tool.CacheClass;

public class SysInfo {

	//新鲜宝  系统版本更新检查
	public static Object resultSysVerson(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		if (CacheClass.isEmpty(DataObj.name)) {
			DataObj.pos = "newandroid";
		}

		SysVersionDataClass tmp = CacheClass.getSYS_VersonCacheManager().Load_Verson(DataObj.name);
		if (tmp == null) {
			throw new LzPluginException("无版本号或取版本号出错 ");
		}

		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取版本号成功";
		data.name = tmp.name;
		data.updatetime = tmp.updatetime;
		data.verson = tmp.verson;
		data.downloadurl = tmp.downloadurl;
		data.msg = tmp.message;
		data.type = tmp.state;
		
		return data;			
	}
	
	//新鲜宝  提现选择金额项	
	public static Object withdraw_RMB_LIST(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)

		ArrayList<SysRmbSelectdataClass> listArry =SysRmbSelect_CacheManager.getInstance().load_sys_RmbSelect_state1();
		if (listArry == null) {
			throw new LzPluginException("无选择金额项 ");
		}
		ArrayList<Object> list=null;
		if(listArry.size()>0)
		{
			list = new ArrayList<Object>();
			list.addAll(listArry);
		}
			int isfreedom=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("isfreedom").trim());
			int freedommin=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("freedommin").trim());
			int freedommax=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("freedommax").trim());
			int freedomrate=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("freedomrate").trim());
			
		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取版本号成功";
		data.isfreedom=isfreedom+"";
		data.freedommin=freedommin+"";
		data.freedommax=freedommax+"";
		data.freedomrate=freedomrate+"";
		data.list = list;
		
		return data;			
	}	
	
	
	
	//新鲜宝  提现多少天多少次参数
	public static Object withdraw_Day_NUM(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int withdrawDay=CacheClass.getIntValue(BaseDataCacheManager.getInstance().Load_Param("withdrawDay"));
		int withdrawDayShow=CacheClass.getIntValue(BaseDataCacheManager.getInstance().Load_Param("withdrawDayShow"));
		int withdrawNum=CacheClass.getIntValue(BaseDataCacheManager.getInstance().Load_Param("withdrawNum"));
		float withdrawMax=CacheClass.getFloatValue(BaseDataCacheManager.getInstance().Load_Param("withdrawMax"));
		
		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取参数成功";
		data.msg = withdrawDayShow+"天内最多提现"+withdrawNum+"次，每次提现最大金额为可用金额的"+withdrawMax+"%";
		
		return data;			
	}		
	
	
	//&新鲜宝 众筹项目种类
	public static Object Project_Cate_List(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		List<SysProjectCateDataClass> list=CrowdSysCateCache.getInstance().loadProjectCateJson();

		List<Object> objlist= new ArrayList<Object>();
		objlist.addAll(list);
		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取项目种类成功";
		data.list = objlist;
		
		return data;			
	}	
		


	//新鲜宝  系统版本更新检查
	public static Object GET_SYS_OPERATION_Params(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)

		int sysTest=CacheClass.getIntValue(BaseDataCacheManager.getInstance().Load_Param("sysTest"));

		CrowdSysParamDataClass param=new CrowdSysParamDataClass();
		param.sysTest=sysTest+"";
		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取系统参数成功";
		data.obj = param;
		
		return data;			
	}
	
		

	
	
}
